BITS 32
%include "macrosmodoprotegido.mac"
;void kprintf(char* msj, int color, int fila, int columna);

%define msj [ebp+8]
%define color [ebp+12]
%define f [ebp+16]
%define c [ebp+20]

global kprintf
kprintf:
	push ebp
	mov ebp, esp
	push ebx
	push esi
	push edi
	push eax

	; origen: segmento del mensaje
	mov ax, ds
	push eax
	mov ax, es
	push eax
	
	mov eax, 0x10
	mov ds, ax
	
	

	; accedo al segmento de video
	mov eax, 0x18	
	mov es, ax

	; esi = *msj	
	mov esi, msj
	
	; edi = offset en memoria
	mov eax, f
	mov ebx, 80
	mul bx
	shl eax, 1
	
	mov edi, eax
	add edi, c
	add edi, c
	
	; eax = color
	mov eax, color
	shl eax, 8
	
.ciclo:
	lodsb
	stosw
	cmp [ds:esi], byte 0
	
	jnz .ciclo
	
	pop eax
	mov es, ax
	pop eax
	mov ds, ax
	
	
	pop eax	
	pop edi
	pop esi
	pop ebx	
	pop ebp
	ret
